package fr.afcepf.al23.qualite.data;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.ResourceBundle;
import java.util.logging.Logger;

import javax.sql.DataSource;

/**
 * Datasource pour la connection au schéma al23_qualite
 * @author Stagiaires
 *
 */
public class QualiteDataSource implements DataSource {
    /**
     * Variable representant le driver.
     */
    private static String driver;
    /**
     * Variable representant l'url de connexion.
     */
    private static String url;
    /**
     * Variable representant le login.
     */
    private static String login;
    /**
     * Variable representant le mot de passe.
     */
    private static String mdp;


    static {
        ResourceBundle rb = ResourceBundle.getBundle("qualite");

        try {
            driver=rb.getString("driver");
            Class.forName(driver);
            login=rb.getString("login");
            mdp=rb.getString("mdp");
            url=rb.getString("url");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }



    }

    @Override
    public Connection getConnection() throws SQLException {
        Connection cnx = null;
        cnx = DriverManager.getConnection(url, login, mdp);
        return cnx;
    }

    @Override
    public PrintWriter getLogWriter() throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public int getLoginTimeout() throws SQLException {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void setLogWriter(PrintWriter paramArg0) throws SQLException {
        // TODO Auto-generated method stub

    }

    @Override
    public void setLoginTimeout(int paramArg0) throws SQLException {
        // TODO Auto-generated method stub

    }

    @Override
    public boolean isWrapperFor(Class<?> paramArg0) throws SQLException {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public <T> T unwrap(Class<T> paramArg0) throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }



    @Override
    public Connection getConnection(String paramArg0, String paramArg1)
            throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }

    /**
     * 
     */
    public QualiteDataSource() {
        super();
        // TODO Auto-generated constructor stub
    }



}
